package com.xmx.mallcenter.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import com.xmx.mallcenter.entity.IssueEntity;
import com.xmx.mallcenter.service.IssueService;
import com.xmx.common.utils.PageUtils;
import com.xmx.common.utils.R;
import io.swagger.annotations.Api;


/**
 * 常见问题表
 *
 * @author fbb
 * @email boyinbing@126.com
 * @date 2021-08-12 01:42:20
 */
@Api(tags = "IssueController", description = "常见问题表服务")
@RestController
@RequestMapping("mallcenter/issue")
public class IssueController {
    @Autowired
    private IssueService issueService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("mallcenter:issue:list")
    @ApiOperation("获取所有常见问题表信息")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = issueService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("mallcenter:issue:info")
    @ApiOperation("获取指定id的常见问题表详情")
    public R info(@PathVariable("id") Integer id){
		IssueEntity issue = issueService.getById(id);

        return R.ok().put("issue", issue);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("添加常见问题表信息")
    //@RequiresPermissions("mallcenter:issue:save")
    public R save(@RequestBody IssueEntity issue){
		issueService.save(issue);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation("更新指定id常见问题表信息")
    //@RequiresPermissions("mallcenter:issue:update")
    public R update(@RequestBody IssueEntity issue){
		issueService.updateById(issue);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @ApiOperation("删除指定id常见问题表信息")
    //@RequiresPermissions("mallcenter:issue:delete")
    public R delete(@RequestBody Integer[] ids){
		issueService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
